Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: service-registry #396

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: service-registry #396

wants to merge 2 commits into from

Conversation

anuragxxd
Copy link
Member

@anuragxxd anuragxxd commented Feb 6, 2025

Description

Migrate Service Registry from https://github.com/elixir-cloud-aai/web-components

Checklist

  • My code follows the contributing guidelines of this project.
  • I am aware that all my commits will be squashed into a single commit, using the PR title as the commit message.
  • I have performed a self-review of my own code.
  • I have commented my code in hard-to-understand areas.
  • I have updated the user-facing documentation to describe any new or changed behavior.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have not reduced the existing code coverage.

Comments

Copy link

changeset-bot bot commented Feb 6, 2025

⚠️ No Changeset found

Latest commit: 2905312

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

sourcery-ai bot commented Feb 6, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new service-registry feature by implementing a suite of web components based on LitElement for managing service registrations. The changes include components for displaying services in a collection view, a form component for creating new services, API integration for fetching and creating service entries, as well as supporting configuration files, demos, documentation, and licensing updates.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Implemented the Services Component for listing and managing services.
  • Added a LitElement-based component for listing services with pagination, filtering, and dynamic details rendering.
  • Handled async fetching of services with error management and caching.
  • Integrated the component with a pre-built design system for rendering collections and details.
packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts
packages/ecc-client-ga4gh-service-registry/src/components/services/services.styles.ts
packages/ecc-client-ga4gh-service-registry/src/components/services/index.ts
Implemented the Create-Service Component for registering new services.
  • Built a LitElement-based form component to capture service information with proper validation.
  • Configured nested form fields to correctly map service structure.
  • Integrated the component with an API method to post new service data and dispatch an event on success.
packages/ecc-client-ga4gh-service-registry/src/components/create-service/create-service.ts
packages/ecc-client-ga4gh-service-registry/src/components/create-service/create-service.styles.ts
packages/ecc-client-ga4gh-service-registry/src/components/create-service/index.ts
Added API integration for service operations.
  • Created helper functions to perform GET and POST requests for fetching and creating services.
  • Implemented error handling in API calls to provide descriptive messages on failure.
packages/ecc-client-ga4gh-service-registry/src/API/Service/serviceGet.ts
Updated package configuration and build setup.
  • Added package.json with scripts, dependencies and exports for the service-registry package.
  • Included tsconfig files for development and production builds.
  • Updated build, lint, and testing configurations along with package-lock.json updates.
packages/ecc-client-ga4gh-service-registry/package.json
packages/ecc-client-ga4gh-service-registry/tsconfig.json
packages/ecc-client-ga4gh-service-registry/tsconfig.prod.json
package-lock.json
Provided demos and documentation for the new components.
  • Added demo HTML pages for both the services and create-service components.
  • Included a README file with an overview and usage instructions.
  • Configured web-dev-server settings for live development and demo preview.
packages/ecc-client-ga4gh-service-registry/demo/index.html
packages/ecc-client-ga4gh-service-registry/demo/register/index.html
packages/ecc-client-ga4gh-service-registry/demo/services/index.html
packages/ecc-client-ga4gh-service-registry/web-dev-server.config.mjs
packages/ecc-client-ga4gh-service-registry/README.md
Incorporated licensing and event exports.
  • Added an Apache License file to the repository.
  • Defined custom event types for service creation, deletion, and update.
packages/ecc-client-ga4gh-service-registry/LICENSE.hbs
packages/ecc-client-ga4gh-service-registry/src/events/index.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elixir-cloud-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 10:38pm

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @anuragxxd - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Avoid hardcoding secrets in source code. (link)
  • Avoid hardcoding secrets in source code. (link)

Overall Comments:

  • Clean up commented-out debug logs to keep the code tidy.
  • Address or explicitly mark the pending implementation for the delete service functionality to clarify its status.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🔴 Security: 2 blocking issues
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

});

if (!response.ok) {
throw new Error("Failed to fetch services");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Enhance error handling with more specific error messages

Consider including the HTTP status code and response body in the error message to help with debugging. You could also create custom error types for different failure scenarios.

Suggested implementation:

  if (!response.ok) {
    const errorBody = await response.text();
    throw new ServiceFetchError(
      `Failed to fetch services: ${response.status} ${response.statusText}`,
      response.status,
      errorBody
    );
  }
export class ServiceFetchError extends Error {
  constructor(
    message: string,
    public status: number,
    public body: string
  ) {
    super(message);
    this.name = 'ServiceFetchError';
  }
}

export async function fetchServices(

Comment on lines +1 to +3
# @elixir-cloud/service-registry

The `@elixir-cloud/service-registry` package provides a suite of Web Components designed to interact with the Service Registry API. These components offer a user-friendly interface for managing service registrations within cloud environments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Expand the README to provide more context and details about the package's functionality.

The README could benefit from a more detailed explanation of the package's purpose and use cases. For example, mentioning specific functionalities like service registration, search, or management would be helpful. Also, clarifying the target cloud environment (e.g., GA4GH compliant clouds) would provide valuable context.

Suggested change
# @elixir-cloud/service-registry
The `@elixir-cloud/service-registry` package provides a suite of Web Components designed to interact with the Service Registry API. These components offer a user-friendly interface for managing service registrations within cloud environments.
# @elixir-cloud/service-registry
The `@elixir-cloud/service-registry` package provides a suite of Web Components designed to interact with the Service Registry API, specifically tailored for GA4GH (Global Alliance for Genomics and Health) compliant cloud environments. These components offer a user-friendly interface for discovering, registering, and managing bioinformatics services within the ELIXIR Cloud ecosystem.
## Overview
This package is part of the ELIXIR Cloud Computing framework and enables seamless integration with GA4GH-compliant service registries. It helps researchers and developers to:
- Discover available bioinformatics services and workflows
- Register new services with standardized metadata
- Manage and update existing service registrations
- Search and filter services based on various criteria
- Monitor service health and availability
## Key Features
- **Service Discovery**: Easy-to-use components for searching and browsing available services
- **Registration Management**: Intuitive interfaces for registering and updating services
- **GA4GH Compliance**: Full support for GA4GH service registry specifications
- **ELIXIR Integration**: Seamless integration with other ELIXIR Cloud services
- **Customizable UI**: Flexible Web Components that can be styled to match your application

render(
html`<ecc-client-ga4gh-service-registry-create-service
baseURL="https://cloud-registry.2.rahtiapp.fi/ga4gh/registry/v1"
authToken="eyJraWQiOiJyc2ExIiwidHlwIjoiYXQrand0IiwiYWxnIjoiUlMyNTYifQ.eyJhdWQiOiI1ZmM2NjAxMC1hNTk2LTQ4ZTQtOGMwOS04OWE3NjdlZjEzNmMiLCJzdWIiOiJhMTE0YmJiMGRiMDNkN2JiYzVjOTM5ODZmNTk1ZGMxZTBlYmNkODlmQGVsaXhpci1ldXJvcGUub3JnIiwiYWNyIjoiaHR0cHM6Ly9yZWZlZHMub3JnL3Byb2ZpbGUvc2ZhIiwic2NvcGUiOiJlZHVwZXJzb25fZW50aXRsZW1lbnQgZW1haWwgZ2E0Z2hfcGFzc3BvcnRfdjEgb3BlbmlkIHByb2ZpbGUiLCJhdXRoX3RpbWUiOjE3Mzg4NzcwNzgsImlzcyI6Imh0dHBzOi8vbG9naW4uZWxpeGlyLWN6ZWNoLm9yZy9vaWRjLyIsImV4cCI6MTczODg5MTQ4MywiaWF0IjoxNzM4ODc3MDgzLCJjbGllbnRfaWQiOiI1ZmM2NjAxMC1hNTk2LTQ4ZTQtOGMwOS04OWE3NjdlZjEzNmMiLCJqdGkiOiI0NWUwMmYzYy04NDdhLTQ4ZjQtOTZkMC0wOGRlYzNjZGJlMWQifQ.rNoFlHqwToFM0Y77Mbhe2bwFFtOmHWwVZh-IrcuyfXX1FkhWY8RyX9tSxUwfem8ns7q40wxKfcrFq-LDK17IunnJT0JAB-_1_U-lfkhsKOO9eAY0UUJtRdoKI1qgp5teEb54EBpkX2twPlaPCI0DLQFRE46EZKWZUeRvOpuGEnwObO34iW0aNPXEUDw_gzG-_rdUNpb0MRlMwIbHUUba-9tHS33-TeuSpjxAJ_EMEt3TJfaYYEYHENhqzJxNtzK8DYwDENR82L9kwEzO497zMcsA99wlfXOtSCauwa5GbzV5rPgNVchiDkb-c877U0nQCIBs3gWsZHbCckRiegOvAA"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Avoid hardcoding secrets in source code.

The authToken value appears to be a hardcoded secret. This is a security risk and should be avoided. Consider storing secrets securely and retrieving them during runtime.

render(
html`<ecc-client-ga4gh-service-registry-services
baseURL="https://cloud-registry.2.rahtiapp.fi/ga4gh/registry/v1"
authToken="eyJraWQiOiJyc2ExIiwidHlwIjoiYXQrand0IiwiYWxnIjoiUlMyNTYifQ.eyJhdWQiOiI1ZmM2NjAxMC1hNTk2LTQ4ZTQtOGMwOS04OWE3NjdlZjEzNmMiLCJzdWIiOiJhMTE0YmJiMGRiMDNkN2JiYzVjOTM5ODZmNTk1ZGMxZTBlYmNkODlmQGVsaXhpci1ldXJvcGUub3JnIiwiYWNyIjoiaHR0cHM6Ly9yZWZlZHMub3JnL3Byb2ZpbGUvc2ZhIiwic2NvcGUiOiJlZHVwZXJzb25fZW50aXRsZW1lbnQgZW1haWwgZ2E0Z2hfcGFzc3BvcnRfdjEgb3BlbmlkIHByb2ZpbGUiLCJhdXRoX3RpbWUiOjE3Mzg4NzcwNzgsImlzcyI6Imh0dHBzOi8vbG9naW4uZWxpeGlyLWN6ZWNoLm9yZy9vaWRjLyIsImV4cCI6MTczODg5MTQ4MywiaWF0IjoxNzM4ODc3MDgzLCJjbGllbnRfaWQiOiI1ZmM2NjAxMC1hNTk2LTQ4ZTQtOGMwOS04OWE3NjdlZjEzNmMiLCJqdGkiOiI0NWUwMmYzYy04NDdhLTQ4ZjQtOTZkMC0wOGRlYzNjZGJlMWQifQ.rNoFlHqwToFM0Y77Mbhe2bwFFtOmHWwVZh-IrcuyfXX1FkhWY8RyX9tSxUwfem8ns7q40wxKfcrFq-LDK17IunnJT0JAB-_1_U-lfkhsKOO9eAY0UUJtRdoKI1qgp5teEb54EBpkX2twPlaPCI0DLQFRE46EZKWZUeRvOpuGEnwObO34iW0aNPXEUDw_gzG-_rdUNpb0MRlMwIbHUUba-9tHS33-TeuSpjxAJ_EMEt3TJfaYYEYHENhqzJxNtzK8DYwDENR82L9kwEzO497zMcsA99wlfXOtSCauwa5GbzV5rPgNVchiDkb-c877U0nQCIBs3gWsZHbCckRiegOvAA"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Avoid hardcoding secrets in source code.

The authToken value appears to be a hardcoded secret. This is a security risk and should be avoided. Consider storing secrets securely and retrieving them during runtime.

Comment on lines +21 to +22
const data = await response.json();
return data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable)

Suggested change
const data = await response.json();
return data;
return await response.json();


ExplanationSomething that we often see in people's code is assigning to a result variable
and then immediately returning it.

Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.

Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant